import logging
import otherMod

logging.basicConfig(filename="sample.log", level=logging.INFO)
log = logging.getLogger("exception")

logging.debug("This is a debug message")
logging.info("Informational message")
logging.error("An error has happened!")

try:
    raise RuntimeError
except RuntimeError:
    log.exception("Error!")


def main():
    logger = logging.getLogger("exampleApp")
    logger.setLevel(logging.INFO)
    # create the logging file handler
    fh = logging.FileHandler("new_snake.log")
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    fh.setFormatter(formatter)
    # add handler to logger object
    logger.addHandler(fh)

    logger.info("Program started")
    result = otherMod.add(7, 8)
    logger.info("Done!")


if __name__ == '__main__':
    main()
